import { GCellRenderer } from "../../../../com/mui/controls/GCellRenderer";
import { BaseItem } from "../common/BaseItem";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { ImagesConst } from "../../resource/ImagesConst";
import { SDrawPlateSingleReward } from "../../../../Message/Game/SDrawPlateSingleReward";
import { ItemData } from "../../resource/info/ItemData";
import { FilterConst } from "../../../component/gconst/FilterConst";
type int = number;
//class AwardsListRenderer
    
    export  class AwardsListRenderer extends GCellRenderer
    {
        constructor()
        {
            super();
            this.initItem();
            return;
        }

        /* internal  */initItem(): void
        {
            this.doubleClickEnabled = false;
            this._good = new BaseItem();
            this._good.setSize(32, 32);
            this._good.move(2, 2);
            this._good.isDragAble = false;
            this._good.isDropAble = false;
            this._good.isShowLock = true;
            this._good.isThrowAble = false;
            this._goodBg = new Object /* flash.display.Bitmap */();
            addChild(this._goodBg);
            this._goodBg.bitmapData = GlobalClass.getBitmapData(ImagesConst.PackItemBg);
            addChild(this._good);
            this._good.addEventListener(flash.events.MouseEvent.CLICK, this.onClick);
            return;
        }

        protected onClick(arg1: Object /* flash.events.MouseEvent */): void
        {
            arg1.stopImmediatePropagation();
            return;
        }

        public /* override */ set data(arg1: Object)
        {
            super.data = arg1;
            this._obj = arg1 as SDrawPlateSingleReward;
            this._good.itemData = new ItemData(this._obj.code);
            this._good.setAmountText(this._obj.num);
            var loc1=(this._obj.order - 1) % 12 + 1;
            var loc2=this.drawBg(225, 248, 469, 12, loc1);
            this.x = loc2.x;
            this.y = loc2.y;
            if (this._obj.type != 0) 
            {
                if (this._obj.type == 1 || this._obj.type == 2) 
                {
                    this._good.filters = [FilterConst.colorFilter2];
                }
                else if (this._obj.type == 3 || this._obj.type == 4) 
                {
                    this._good.filters = [FilterConst.itemChooseFilter];
                }
            }
            else 
            {
                this._good.filters = null;
            }
            return;
        }

        public drawBg(arg1: int, arg2: int, arg3: int, arg4: int, arg5: int, arg6: int=0): Object /* flash.geom.Point */
        {
            var loc3=0;
            var loc1=360 / arg4;
            var loc2=2 * Math.sin(loc1 / 2 * Math.PI / 180) * arg1;
            if (arg6 != 0) 
            {
                if (arg6 == 1) 
                {
                    this.goodX = arg2;
                    this.goodY = arg3 - arg1;
                    this.angle2 = (-loc1) / 2;
                    loc3 = loc1 / 2;
                }
            }
            else 
            {
                this.goodX = arg2 - Math.sin(loc1 / 2 * Math.PI / 180) * arg1;
                this.goodY = arg3 - Math.cos(loc1 / 2 * Math.PI / 180) * arg1;
                this.angle2 = -loc1 - 15;
                loc3 = loc1;
            }
            this.angle2 = this.angle2 + arg5 * loc3;
            var loc4=Math.cos(this.angle2 * Math.PI / 180) * loc2;
            var loc5=Math.sin(this.angle2 * Math.PI / 180) * loc2;
            this.goodX = this.goodX + loc4;
            this.goodY = this.goodY + loc5;
            this.goodPt = new Object /* flash.geom.Point */(this.goodX, this.goodY);
            return this.goodPt;
        }

        /* internal */ /* var */_good: BaseItem;

        /* internal */ /* var */_goodBg: Object /* flash.display.Bitmap */;

        /* internal */ /* var */goodX: number;

        /* internal */ /* var */goodY: number;

        /* internal */ /* var */goodPt: Object /* flash.geom.Point */;

        /* internal */ /* var */angle2: int;

        /* internal */ /* var */_obj: SDrawPlateSingleReward;
    }
